	<SCRIPT language="javascript">
		function addRow(tableID) {

			var table = document.getElementById(tableID);

			var rowCount = table.rows.length;
			var row = table.insertRow(rowCount);

			var colCount = table.rows[0].cells.length;

			for(var i=0; i<colCount; i++) {

				var newcell	= row.insertCell(i);

				newcell.innerHTML = table.rows[0].cells[i].innerHTML;
				//alert(newcell.childNodes);
				switch(newcell.childNodes[0].type) {
					case "text":
							newcell.childNodes[0].value = "";
							break;
					case "checkbox":
							newcell.childNodes[0].checked = false;
							break;
					case "select-one":
							newcell.childNodes[0].selectedIndex = 0;
							break;
				}
			}
		}

		function deleteRow(tableID) {
			try {
			var table = document.getElementById(tableID);
			var rowCount = table.rows.length;

			for(var i=0; i<rowCount; i++) {
				var row = table.rows[i];
				var chkbox = row.cells[0].childNodes[0];
				if(null != chkbox && true == chkbox.checked) {
					if(rowCount <= 1) {
						alert("Setidaknya ada satu kelas.");
						break;
					}
					table.deleteRow(i);
					rowCount--;
					i--;
				}


			}
			}catch(e) {
				alert(e);
			}
		}

	</SCRIPT>

<div class="table_filter_wrapper">
	<INPUT type="button" value="Tambah Kelas" onclick="addRow('dataTable')" />
	<INPUT type="button" value="Hapus Kelas" onclick="deleteRow('dataTable')" />
</div>
	<TABLE id="dataTable" width="200px" border="0">
		<?php
			foreach($kelas as $row):
		?>
		<TR>		
			<TD><INPUT type="checkbox" name="chk[]"/></TD>
			<TD>
				<label for="class_name">Nama Kelas</label>
				<?php echo form_error('class_name[]', '<div class="error">', '</div>'); ?>
				<INPUT type="text" name="class_name[]" class="text" value="<?php echo $row['class_name']; ?>"/>
				<label for="cost">Harga</label>
				<?php echo form_error('cost[]', '<div class="error">', '</div>'); ?>
				<INPUT type="text" name="cost[]" class="text" value="<?php echo $row['cost']; ?>" />
				<label for="percent_disc">Diskon</label>
				<INPUT type="text" name="percent_disc[]" class="text" value="<?php echo $row['percent_disc']; ?>" />
			</TD>
		</TR>		
		<?php
			endforeach;
		?>
		
	</TABLE>
